﻿using FluentValidation;
using MediatR;

namespace FluentValidationExample.Application.Customers.Commands;

public sealed record CreateCommand(Guid Id, string Name, string Code) : IRequest;

public class CreateCommandValidation : AbstractValidator<CreateCommand>
{
    public CreateCommandValidation()
    {
        RuleFor(x => x.Name).NotEmpty().WithMessage("客户名称不能为空");

        RuleFor(x => x.Name).MinimumLength(6).WithMessage("客户名称最少6位");
        
        RuleFor(x => x.Code).NotEmpty().WithMessage("客户编码不能为空");
    }
}